#!/bin/bash
# Author : Syuan-Rong Chen
# E-mail : calvin.atx@gmail.com
# Blog：   http://calvinit.blogspot.com
# Date : 20100812
#
# <description>
# Copyright (C) <year>  <name> <email>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#
temp=$1

[ -z $temp ] && echo "ERROR:不得為空值" && exit 99
if [ -f $temp ]; then
	echo "檔案已存在,是否移除?[y/n]"
	read -e ans
	case $ans in
		y) rm -rf $temp ;;
	        n) exit 1 ;;
		*) 
		   echo "請輸入y或n"
		   filecheck
		   ;;
	esac	
fi

touch $temp
chmod +x $temp
echo "#!/bin/bash" > $temp
echo "# Author： Syuan-Rong Chen" >> $temp
echo "# E-mail： calvin.atx@gmail.com" >> $temp
echo "# Blog：   http://calvinit.blogspot.com" >> $temp
echo -e "# Date : \c" >> $temp
date +%Y%m%d >> $temp

function GPLQ { 
read -p "加入GPLv2宣告?[y/n] : " gp 

case "$gp" in
	y)
		cat /usr/cbin/c/0-GPLv2 >> $temp
		;;
	n)
		;;
	*)
		echo "請輸入y或n" 
		GPLQ
		;;
esac
}
GPLQ

function dSH { 
read -p "使用.sh作為副檔名?[y/n] : " gp 

case "$gp" in
	y)
		mv $temp $temp.sh
		nano $temp.sh
		;;
	n)
		nano $temp
		;;
	*)
		echo "請輸入y或n" 
		dSH
		;;
esac
}
dSH
